<?php

require_once(dirname(__DIR__) . '/api/DB.php');
require_once(dirname(__DIR__) . '/api/response.php');

$message = '';

try {

    $db = new DB();
    $pdo = $db::$pdo;

    // 查询分类
    $sql = 'select * from categories';
    $stmt = $pdo->prepare($sql);
    $stmt->execute();

    myResponse('', 1, 200, $stmt->fetchAll(PDO::FETCH_ASSOC));
} catch (Exception $e) {
    $message = $e->getMessage();
    myResponse($message, 0, 200);
}